{{>licenseInfo}}

import { AlfrescoApi } from '../../../alfrescoApi';
import { AlfrescoApiClient, RequestOptions } from '../../../alfrescoApiClient';

export class BaseApi {

    apiClient: AlfrescoApiClient;

    constructor(alfrescoApi?: AlfrescoApi) {
        if (alfrescoApi) {
            this.apiClient = alfrescoApi.contentClient;
        }
    }

    post<T = any>(options: RequestOptions): Promise<T> {
        return this.apiClient.post<T>(options);
    }

    put<T = any>(options: RequestOptions): Promise<T> {
        return this.apiClient.put<T>(options);
    }

    get<T = any>(options: RequestOptions): Promise<T> {
        return this.apiClient.get<T>(options);
    }

    delete<T = void>(options: RequestOptions): Promise<T> {
        return this.apiClient.delete(options);
    }

    errorMessage(param: string, methodName: string) {
        return `Missing param ${param} in ${methodName}`;
    }
}
                            